package com.gongyi.mapper;

import com.gongyi.pojo.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

/**
 * @Classname UserMapperImpl
 * @Description TODO
 * @Date 2022/1/22 19:21
 * @Created by Administrator
 */
public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper {


    @Override
    public List<User> selectUser() {
        User user = new User(5, "小强", "202201222015");
        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        mapper.addUser(user);
        mapper.deleteUser(4);//模拟异常：sql中的delete写成deletes
        return mapper.selectUser();

    }

    @Override
    public int addUser(User user) {
        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }
}
